#include<bits/stdc++.h>
using namespace std;
int T,ans1,ans2;
int p[100010],sum[100010];
map<int,map<int,bool>>flag;
int F[100010];
struct node{
int d,v,a;
}f[100010];
int n,m,L,V;
int check(){
for(int i=1;i<=n;i++)if(F[i])return 0;
    return 1;
}
void change1(){
ans1=ans2=0;
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
        flag[i][j]=false;
    }
    for(int i=1;i<=n;i++){
        cin>>f[i].d>>f[i].v>>f[i].a;
    }for(int i=1;i<=m;i++)cin>>p[i];
    for(int i=1;i<=n;i++){
            int fl=1;
    for(int j=1;j<=m;j++){
            if(p[j]>=f[i].d){
        double v=sqrt(f[i].v*f[i].v+2*f[i].a*(p[j]-f[i].d));
        if(v>V)ans1+=fl,fl=0,flag[i][j]=true,sum[j]++;
        }
    }
    if(fl==0)F[i]=1;
    }
}
int main(){
freopen("detect.in","r",stdin);
freopen("detect.out","w",stdout);
cin>>T;
while(T--){
    change1();
    while(!check()){
    int maxn=-1,l=0;
    for(int i=1;i<=m;i++){
        if(sum[i]>maxn)maxn=sum[i],l=i;
    }
    if(l==0)break;
        for(int i=1;i<=n;i++)
    if(flag[i][l]){
    F[i]=0;
    for(int j=1;j<=m;j++){
        if(flag[i][j])flag[i][j]=0,sum[j]--;
    }
    }
    ans2++;
    }
    cout<<ans1<<" "<<m-ans2<<endl;
}
return 0;
}
